xen/timers: Document and improve the representation of the timer heap metadata
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 29 Mar 2019 13:32:09 +0000 (13:32 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 29 Mar 2019 18:28:21 +0000 (18:28 +0000)
commit12381e20b5c2cb2f54601bef47c4f6e43acf3833
tree3bbb8a9e3c50d40d36270c2f0b24f71e7b934aff
parent753ba43d6d16e688f688e01e1c77463ea2c6ec9f
xen/timers: Document and improve the representation of the timer heap metadata

The {GET,SET}_HEAP_{SIZE,LIMIT}() macros implement some completely
undocumented pointer misuse to store the size and limit information.  In
practice, heap[0] is never a timer pointer, and used to stash the metadata
instead.

Extend the HEAP OPERATIONS comment to include this detail.  Introduce a
structure representing the heap metadata, and a static inline function to
perfom the type punning.

Replace all of the above macros with an equivelent expression involving the
heap_metadata() helper.  Note that I deliberately haven't rearranged the
surrounding code - this allows the correctness of the transformation to be
checked by confirming that the compiled binary is identical.

This also removes two cases of a macro argument with side effects, which only
worked correctly because the arguments were only evaluated once.

Finally, fix up the type of dummy_heap.  The old code functioned correctly,
but only by virtue of confusing a discrete object and a single-entry array.
Change its type to match the intended semantics, and drop the redundant
initialisation in timer_init().

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/timer.c